package com.wenan.ui.controls.charts
{
	import com.amcharts.axes.ValueAxis;
	import com.amcharts.chartClasses.AmBalloon;
	import com.amcharts.chartClasses.ChartCursor;
	import com.amcharts.chartClasses.ChartScrollbar;
	import com.wenan.ui.controls.charts.expand.AmChartSpecial;
	import com.wenan.ui.controls.charts.expand.CategoryAxisExpand;
	import com.wenan.ui.controls.charts.property.Heading;
	import com.wenan.ui.controls.listBoxes.TitleCheckListBox;
	
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.text.StyleSheet;
	
	import mx.collections.ArrayCollection;
	import mx.containers.Canvas;
	import mx.containers.HBox;
	import mx.containers.VBox;
	import mx.controls.Image;
	import mx.controls.Label;
	import mx.core.UIComponent;
	import mx.events.FlexEvent;
	import mx.states.SetStyle;

	
	public class SuperAmChartsModule
	{
		[Embed('assets/charts/axisArrow2.png')]
		public var axisArrowX:Class;
		[Embed('assets/charts/axisArrow1.png')]
		public var axisArrowY:Class;  
		
		[ArrayElementType("uint")]
		public var colors:ArrayCollection = new ArrayCollection();
		
		public var dataProvider:Object;
		public var reportBox:VBox;
		public var dateLabel:Label = new Label();
		public var acs:AmChartSpecial;
		public var yDefaultData:ArrayCollection = new ArrayCollection();
		public var xDefaultData:ArrayCollection = new ArrayCollection();
		public var xHeading:Heading = new Heading();
		public var yHeading:Heading = new Heading();
		public var balloonText:String = "[[category]]: [[value]]";		//提示信息显示方式
		public var depth3D:int = 30;									//显示3D效果
		public var angle:int = 30;										//y轴以3D显示
		public var labelRotation:int = 45;
		public var titleName:String;											//报表标题
		public var titleSize:int = 20;											//报表标题字体大小
		public var titleColor:uint = 0x215B8D									//报表标题颜色
		public var cs:ChartScrollbar;
		
		//------------------
		public var cblRow:TitleCheckListBox = new TitleCheckListBox();
		public var cblRowName:String;
		public var cblRowStyleName:String;
		public var cblRowDataProvider:ArrayCollection;
		public var axisXImage:Image;
		public var axisYImage:Image;
		
		public function SuperAmChartsModule()
		{
			dateLabel.setStyle("color", 0x3A6E9B);
			cs = initChartScrollbar();
			
			axisXImage = new Image();
			axisXImage.source = axisArrowX;
			axisYImage = new Image();
			axisYImage.source = axisArrowY;
		}
		
		public function initializeData():void{}
		public function chartHandler(obj:Object = null):void {}
		public function createReportPanel():UIComponent
		{
			return null;
		}
		
		public function getCategoryAxis():CategoryAxisExpand {
			var categoryAxis:CategoryAxisExpand = new CategoryAxisExpand();
			categoryAxis.gridPosition = "start";
			categoryAxis.gridAlpha = 0.1;
			categoryAxis.wrapLabels = true;
			if (dataProvider)
			{
				categoryAxis.setStyle("gridCount", (dataProvider as ArrayCollection).length);
			}
			categoryAxis.setStyle("axisColor", 0x3F8AD6);
			categoryAxis.setStyle("axisThickness", 1.5);
			categoryAxis.title = xHeading.title;
			categoryAxis.titleTextColor = xHeading.titleTextColor;
			categoryAxis.titleTextSize = xHeading.titleTextSize;
			categoryAxis.titleAlignment = xHeading.titleAlignment;
			return categoryAxis;
		}
		
		public function getValueAxis():ValueAxis {
			var valueAxis:ValueAxis = new ValueAxis();
			valueAxis.setStyle("axisColor", 0x3F8AD6);
			valueAxis.setStyle("gridAlpha", 0.1);
			valueAxis.setStyle("axisThickness", 1.5);
			return valueAxis;
		}
		
		public function getValueAxisLeft():ValueAxis {
			var valueAxis:ValueAxis = new ValueAxis();
			valueAxis.position = "left";
			valueAxis.setStyle("axisColor", 0x3F8AD6);
			valueAxis.setStyle("gridAlpha", 0.1);
			valueAxis.setStyle("axisThickness", 1.5);
			valueAxis.title = yHeading.title;
			valueAxis.titleTextColor = yHeading.titleTextColor;
			valueAxis.titleTextSize = yHeading.titleTextSize;
			valueAxis.titleAlignment = yHeading.titleAlignment;
			return valueAxis;
		}
		
		public function getValueAxisBottom():ValueAxis {
			var valueAxis:ValueAxis = new ValueAxis();
			valueAxis.position = "bottom";
			valueAxis.setStyle("axisColor", 0x3F8AD6);
			valueAxis.setStyle("gridAlpha", 0.1);
			valueAxis.setStyle("axisThickness", 1.5);
			valueAxis.title = xHeading.title;
			valueAxis.titleTextColor = xHeading.titleTextColor;
			valueAxis.titleTextSize = xHeading.titleTextSize;
			valueAxis.titleAlignment = xHeading.titleAlignment;
			return valueAxis;
		}
		
		public function getAmBalloon():AmBalloon {
			var amBalloon:AmBalloon = new AmBalloon();
			amBalloon.setStyle("cornerRadius", 8);
			amBalloon.setStyle("borderThickness", 2);
			amBalloon.setStyle("borderColor", 0xFFFFFF);
			amBalloon.setStyle("borderAlpha", 1);
			return amBalloon;
		}
		
		/**
		 * tip小点，能产生吸附的效果
		 * */
		public function getChartCursor():ChartCursor {
			var chartCursor:ChartCursor = new ChartCursor();
			chartCursor.zoomable = false;
			chartCursor.setStyle("cursorAlpha", 0);
			chartCursor.categoryBalloonEnabled = false;
			return chartCursor;
		}
		
		public function initChartScrollbar():ChartScrollbar
		{
			var cs:ChartScrollbar = new ChartScrollbar();
			cs.setStyle("hideResizeGrips", true);
			cs.height = 20;
			return cs;
		}
	}
}